 import 'exchange_card.dart';

class ExchangeUserGroup {
  final String userName; // 用户昵称
  final String userAvatar; // 用户头像url
  final List<ExchangeCard> offerCards; // TA要换出
  final List<ExchangeCard> wantCards;  // TA想换入
  final bool? canExchange; // 是否可交换

  ExchangeUserGroup({
    required this.userName,
    required this.userAvatar,
    required this.offerCards,
    required this.wantCards,
    this.canExchange,
  });

  factory ExchangeUserGroup.fromJson(Map<String, dynamic> json) {
    return ExchangeUserGroup(
      userName: json['userName'] as String,
      userAvatar: json['userAvatar'] as String,
      offerCards: (json['offerCards'] as List<dynamic>)
          .map((e) => ExchangeCard.fromJson(e as Map<String, dynamic>))
          .toList(),
      wantCards: (json['wantCards'] as List<dynamic>)
          .map((e) => ExchangeCard.fromJson(e as Map<String, dynamic>))
          .toList(),
      canExchange: json['canExchange'] as bool,
    );
  }
}